package com.kasinf.springcloud.controller;

import cn.hutool.core.map.MapUtil;
import com.kasinf.springcloud.entity.CommonResult;
import com.kasinf.springcloud.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author lkhsh
 */
@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap = new HashMap<>() {
        {
            put(1L, new Payment(1L, "02335195955ad646fcabb60e490c8040"));
            put(2L, new Payment(2L, "02ba0e4b5596eeddc2e0baa4048dc476"));
            put(3L, new Payment(3L, "02f6351eb6569ef7c862d0bf11a7326d"));
        }
    };

    @GetMapping("paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id) {
        Payment payment = hashMap.get(id);
        return new CommonResult<>(200, "from mysql,serverPort: " + serverPort, payment);
    }
}
